home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_09_02 / 9n02108a < prev    next >
Text File  |  1990-12-15  |  2KB  |  80 lines

  1.  
  2.  
  3.  
  4. /*Program Test program to turn small letters into Caps.*/
  5. /*R. McLaughlin*/
  6.  
  7. /*Includes*/
  8. #include <stdio.h>
  9. #include <string.h>
  10. #include <ctype.h>
  11. #include <stdlib.h>
  12. #include <cm.h>  /*CHECK*MATE include*/
  13. #include <setups.h>  /*routines to set up serial port*/
  14. #include <log.h>  /*routines to log on and off remote
  15. system*/
  16. /*Data Structures*/
  17. #define FALSE 0
  18. int i, correct;
  19. char char_in[2], char_out[2];
  20. char output[81];
  21. char msg[100];
  22.  
  23. /*Code*/
  24. main()
  25. {
  26.       CM_log("Start test of lower-to-upper");
  27.           /*Put start message in test log.*/
  28.       Set_line();  /*implementation dependent*/
  29.       Log_in();    /*implementation dependent*/
  30.       for(i=0;i<1000;i++)
  31.       {
  32.       while(isprint(char_out)=FALSE)
  33.        {
  34.      char_out= char rand();  /*send only printable      
  35.                               characters.*/
  36.        }
  37.            TX_chr(DEV1,char_out);
  38.            TX_chr(DEV1,"\n");
  39.            RX_chr(DEV1,char_in);
  40.            if (islower(char_out)!=FALSE))
  41.                  {
  42.                  if((isupper(char_in)==FALSE) ||
  43.                      (tolower(char_in)==char_out))
  44.                      {
  45.                sprintf(msg,"Sent %c, received %c.  -- 
  46.                FAILURE",char_out,char_in);
  47.                  CM_log(msg);
  48.                      }
  49.                      else
  50.                      {
  51.                      correct++;
  52.                      }
  53.                  else
  54.                      {
  55.                      if(char_out==char_in)
  56.                         {
  57.                         correct++;
  58.                         }
  59.                         else
  60.                         {
  61.                     sprintf(msg,"Sent %c, received %c. 
  62.                     --  FAILURE",char_out,char_in);
  63.                            CM_log(msg);
  64.                         }
  65.                      }
  66.                   }
  67.      sprintf(msg,"Received %d correct
  68.      characters.",correct);
  69.       CM_log(msg);
  70.       CM_log("Test Complete");
  71.       Log_off();     /*implementation dependent*/
  72.       Reset_devices();  /*implementation dependent*/
  73.       exit(0);
  74. }
  75.  
  76.  
  77. Note:  Implementation dependent code is not shown.
  78.  
  79.  
  80.